<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Setting extends MY_Controller {

	function __construct()
    {
		// Call the Model constructor
        parent::__construct();
		if($this->session->userdata('login') === TRUE && in_array(107,$this->access)){
			$log['activity']='VIEW';
			$log['information']='Masuk ke menu : '.$this->uri->uri_string();
			$this->model_log->add($log);
		}else{
			$log['activity']='VIEW';
			$log['information']='Tidak diijinkan : '.$this->uri->uri_string();
			$this->model_log->add($log);
			redirect('sessions/login');
		}
    }
	
	public function index()
	{
		$this->load->model('model_setting');
		
		if(isset($_POST['data'])){
			$record = array();
			$record = $_POST['data'];
			$record['site_offline'] = isset($record['site_offline'])?'yes':'no';
			$record['multi_master'] = isset($record['multi_master'])?'yes':'no';
			$this->model_setting->edit($record);
			redirect('setting');
		}
		$data['setting']= $this->model_setting->get();
		$data['master']= $this->model_master->get_all();
		$data['account']= $this->model_coa->get_tree();
		$data['airline'] = $this->model_airline->get_all();
		$data['rekening']= $this->model_acc_bank->get_all();
		
		$params['content']= $this->load->view('form',$data,TRUE);
		
		$params['footer']['js_plugin'] = $this->load->view('js_plugin','',TRUE);
		$params['footer']['js_init'] = $this->load->view('js_init','',TRUE);
		$params['header']['css_plugin'] = $this->load->view('css_plugin','',TRUE);
		
		echo modules::run('template', $params);	
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
